#include "gtest/gtest.h"

#include "recovery/Block.h"
using recovery::InternalBlock;
using recovery::Block;

TEST(InternalBlockTest, testMain){
    InternalBlock * b = InternalBlock::allocate(1024);
    //std::cout << sizeof(*b) << std::endl; // print out: 1
    ASSERT_EQ(0, b->data(0));

    b->data(0) = 100;
    ASSERT_EQ(100, b->data(0));
    InternalBlock::deallocate(b);
}

TEST(BlockTest, testMain){
    Block block(10);
    ASSERT_EQ(10ul, block.len());
    ASSERT_EQ(10*Block::kBlockSize, block.bytes());

    block.data(0)=100;
    ASSERT_EQ(100, block.data(0));

    ASSERT_EQ(100, *(block.addr(0)));

    unsigned char * bufAddr = &(block.data(0));
    ASSERT_EQ(100, *bufAddr);
}
//TODO: BlockTest::out_of_range testcase
//TODO: using of addr() : default & customize
//TODO: using of data() :default & customize
//TODO: read interface for Block
